<?php

class reliquat {

    
        public function dateAction() {

        $form = new ZendX_JQuery_Form();
        $date = new ZendX_JQuery_Form_Element_DatePicker('date', array('label' => 'Date'));
        $date->setJQueryParam('dateFormat', 'dd-mm-yy');
        $form->addElement($date);
        $this->view->form = $form;
    }


    protected function old_initJquery() {

        $this->bootstrap('view');
        $view = $this->getResource('view'); //get the view object
        //add the jquery view helper path into your project
        $view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
        $viewRenderer->setView($view);

        //jquery lib includes here (default loads from google CDN) (Content Delivery Network)
        $view->jQuery()
                ->setVersion('1.6')   //jQuery version, automatically 1.5 = 1.5.latest
                ->setUiVersion('1.8') //jQuery UI version, automatically 1.8 = 1.8.latest
                //->addStylesheet('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.css')//add the css
                ->addStyleSheet($view->baseUrl() . '/js/jquery/themes/ui-lightness/jquery-ui-1.8.16.custom.css')
                ->addJavascriptFile($view->baseUrl() . '/js/jQuery/ui/i18n/jquery-ui-i18n.js')
                ->uiEnable() //enable ui
                ->enable(); //enable jquery ; ->setCdnSsl(true) if need to load from ssl location
    }

    protected function old_initView() {

        // Initialize view
        $view = new Zend_View();
        $view->doctype('HTML5'); //XHTML1_STRICT
        $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8');
        $view->headTitle()->setSeparator(' - ');
        $view->headTitle('Cabinet');

        $view->headLink()->prependStylesheet($view->baseUrl() . '/css/twistter/bootstrap.css')
                ->appendStylesheet($view->baseUrl() . '/css/twistter/docs/assets/css/docs.css')
                ->appendStylesheet($view->baseUrl() . '/css/twister-custom.css');

        // tablesorter.com/docs/index.html
        //$view->headScript()//->appendFile($view->baseUrl() . '/js/jQuery/jquery.tablesorter.min.js')
        //->appendFile($view->baseUrl() . '/js/jQuery/ui/i18n/jquery-ui-i18n.js')
        //        ->appendFile("http://maps.googleapis.com/maps/api/js?key=AIzaSyDFnDa3JOTMdjMEZOYwepTMf_cRBYYjAps&sensor=true");

        return $view;
    }

    protected function old_initJQuery() {

        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
        $viewRenderer->setView($view);

        //ZendX_JQuery_View_Helper_JQuery::enableNoConflictMode();
        // jQuery
        //$view->JQuery()->addStyleSheet($view->baseUrl() . '/js/jquery/themes/ui-lightness/jquery-ui-1.8.16.custom.css');
        //$view->JQuery()->setUiLocalPath($view->baseUrl() . '/js/jquery/ui/jquery-ui-1.8.16.custom.js');

        $view->JQuery()->setLocalPath($view->baseUrl() . '/js/jquery/jquery-1.5.2.min.js') //'/js/jquery/jquery-1.7.1.min.js')
                ->setUILocalPath($view->baseUrl() . '/js/jquery/ui/jquery-ui-1.8.16.custom.js') // '/js/jquery/ui/jquery-ui-1.8.16.custom.js')
                ->addStyleSheet($view->baseUrl() . '/js/jquery/themes/ui-lightness/jquery-ui-1.8.16.custom.css');

        $view->JQuery()->enable();
        $view->JQuery()->uiEnable();
    }

    protected function old_initAutoload() {

        $modelLoader = new Zend_Application_Module_Autoloader(array(
                    'namespace' => '',
                    'basePath' => APPLICATION_PATH));

        $this->_acl = new Cab_Acl_Acl();
        $this->_auth = Zend_Auth::getInstance();
        if (!$this->_auth->hasIdentity()) {
            $this->_auth->getStorage()->read()->role = 'guest';
        }

        $fc = Zend_Controller_Front::getInstance();
        $fc->registerPlugin(new Cab_Controller_Plugin_Acl($this->_acl, $this->_auth));

        return $modelLoader;
    }

    protected function old_initMetadataCache() {

        // First, set up the Cache
        $frontendOptions = array('automatic_serialization' => true);
        $backendOptions = array('cache_dir' => APPLICATION_PATH . '/../cache');
        $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
        //Zend_Debug::dump($cache);
        // Next, set the cache to be used with all table objects
        Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
        Zend_Registry::set('cache', $cache);
    }

    public function old_initDbCache() {
        // bootstrap DB
        $this->bootstrap('db');
        $dbAdapter = $this->getResource('db');

        // bootstrap cache
        $this->bootstrap('cache');

        $cache = $this->getResource('cachemanager');
        Zend_Debug::dump($cache);

        // set db metadata cache
        //Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
    }

//$view->headScript()->appendFile('http//autobahn.tablesorter.com/jquery.tablesorter.min.js');
    // exemple d'inclusion par ordre (offset)
    // mettre les scripts dans l'ordre
    // placer celui-ci à un offset particulier pour s'assurer
    // de le charger en deuxieme
    // ordre = 2
    // $view->headScript()->offsetSetFile(100, '/public/js/myfuncs.js');
    // utiliser les effets de scriptaculous (append utilise
    // l'index suivant, c-à-d. 101)
    // ordre = 3
    // $view->headScript()->appendFile('/public/js/scriptaculous.js');
    // mais dans tous les cas, le script de base prototype
    // doit être chargé en premier :
    // ordre = 1
    // $view->headScript()->prependFile('/public/js/prototype.js');
    //
        // Ajoutons le au ViewRenderer
    //$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
    //$viewRenderer->setView($view);
    // Initialisation d'un autoload pour une application sans module
    // pas necessaire pour l'instant
    protected function _initAutoload() {


        $resourceLoader = new Zend_Application_Module_Autoloader(array(
                    'namespace' => '',
                    'basePath' => APPLICATION_PATH));

        //$resourceLoader->addResourceType('actionhelper', 'controllers/helpers/', 'Action_Helper');
        //var_dump($resourceLoader->getResourceTypes());
    }

    protected function old_initZFDebug() {
// Setup autoloader with namespace
        $autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader->registerNamespace('ZFDebug');

// Ensure the front controller is initialized
        $this->bootstrap('FrontController');

// Retrieve the front controller from the bootstrap registry
        $front = $this->getResource('FrontController');

// Only enable zfdebug if options have been specified for it
        if ($this->hasOption('zfdebug')) {
// Create ZFDebug instance
            $zfdebug = new ZFDebug_Controller_Plugin_Debug($this->getOption('zfdebug'));

// Register ZFDebug with the front controller
            $front->registerPlugin($zfdebug);
        }
// In application.ini do the following:
// 
// [development : production]
// zfdebug.plugins.Variables = null
// zfdebug.plugins.Time = null
// zfdebug.plugins.Memory = null
// ...
// Plugins that take objects as parameters like Database and Cache
// need to be registered manually:
// $zfdebug->registerPlugin(new ZFDebug_Controller_Plugin_Debug_Plugin_Database($db));
// Alternative configuration without application.ini
// $options = array(
//     'plugins' => array('variables', 'database', 
//                        'file' => array('basePath' => '/Library/WebServer/Documents/budget', 'myLibrary' => 'Scienta'),
//                        'memory', 'time', 'registry', 
//                        //'auth',
//                        //'cache' => array('backend' => $cache->getBackend()), 
//                        'exception')
// );
// $zfdebug = new ZFDebug_Controller_Plugin_Debug($options);
// Register ZFDebug with the front controller
// $front->registerPlugin($zfdebug);
    }

    protected function old_initActionHelpers() {
//Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '\controllers\helpers', 'Gl');
//hooks cause action helper to autorun: http://akrabat.com/zend-framework/hooks-in-action-helpers/
// Zend_Controller_Action_HelperBroker::addHelper(new Cab_Action_Helper_HelperAuth());
//Zend_Controller_Action_HelperBroker::addHelper(new Action_Helper_Auth());
//echo APPLICATION_PATH . '/controllers/helpers';
//var_dump(Zend_Controller_Action_HelperBroker::getExistingHelpers());
    }

    protected function _initResourceLoader() {
        $resourceLoader = $this->getResourceLoader();
        $resourceLoader->addResourceType('actionhelper', 'controllers/helpers', 'Action_Helper');
    }

    protected function old_initAcl() {

        $Config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/acl.ini', APPLICATION_ENV);
//$Config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
        $aclModel = new Cab_Acl_Acl($Config); //new Model_Acl($Config);
        Zend_Registry::set('aclModel', $aclModel);
    }

    protected function old_initBaseUrl() {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        return $this->view->baseUrl();
    }

    protected function old_initJavascriptFiles() {
        $this->bootstrap('view');
        $view = $this->getResource('view');
// echo "<h1>" . $view->baseUrl() . "</h1>";
        $view->headLink()->prependStylesheet($view->baseUrl() . '/css/twistter/bootstrap.css');
    }

}